package action.credit;

/*import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.google.gson.Gson;*/

import model.app.AppLoantype;
import model.grant.Customgrant;
import model.personal.Personalbasic;
import model.security.UsrUser;



import java.util.List;
import service.app.CreatKeyService;
import service.credit.AppLoantypeService;
import service.credit.PersonalSearchService;
import service.dropdown.DropDownService;
import service.user.FindAllUserService;
import util.Time;
import core.action.BaseAction;
import exception.Exceptions;

public class SerachPersonalListAjax extends BaseAction {
	
	private String creditName;
	private String certificatenumber;
	private List<Personalbasic> personalList;
	private Personalbasic person;
	private String type;
	private Integer clientID;
	private List<UsrUser> userList;
	
	/*贷款类型列表*/
	private List<AppLoantype> loantypeList;

	private Customgrant customgrant;

	private FindAllUserService findAllUserService;
	private AppLoantypeService appLoantypeService;
	
	private CreatKeyService creatKeyService;
	
	private List<?> dcommonList;
	private DropDownService dropDownService;
	
	private List<?> culturaList;
	
	private int autoApplyId;
	
	private String applydate;
	
	private int isLook;

	public void setCreditName(String creditName) {
		this.creditName = creditName;
	}

	private PersonalSearchService personalSearchService;

	public String loadInfor() throws Exception {
		type = "1";
		this.personalList = this.personalSearchService.get_personalList();
		return "load";
	}

	public String loadInforOne() throws Exceptions {
		type = "1";
		this.applydate = Time.Timestamp2DateString(Time.CurrentTimestamp());
		this.culturaList = this.dropDownService.getCommonList(6, 0);
		this.dcommonList = this.dropDownService.getListBean(2, 0);
		this.autoApplyId = this.creatKeyService.creatKeyFull(41);
		this.loantypeList = this.appLoantypeService.getLoanTypeList();
		this.person = this.personalSearchService.searchOnePerson(clientID);
		return "loadOnePersonal";
	}

	/*public String execute() {
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		if(!this.certificatenumber.equals("")){
				List<Personalbasic> persons = this.personalSearchService.searchPersonalbasicByIdNumber(certificatenumber);
				try {
					if(persons == null){
						out.print("null");
					}else{
					String infor = new Gson().toJson(persons);
					out.print(infor);
					}
				} catch (Exception e1) {
					
				}
		}else if (this.clientID != null) {
			List<Personalbasic> persons = this.personalSearchService
					.searchPersonByID(this.clientID);
			try {
				if (persons == null) {
					out.print("null");
				} else {
					String infor = new Gson().toJson(persons);
					out.print(infor);
				}
			} catch (Exception e1) {

			}
		} else {
			List<Personalbasic> persons = this.personalSearchService
					.searchPersonByName(creditName);
			try {
				if (persons == null) {
					out.print("null");
				} else {
					String infor = new Gson().toJson(persons);
					out.print(infor);
				}
			} catch (Exception e1) {

			}
		}

		try {
			out.flush();
			out.close();
		} catch (Exception e) {

		}
		return "success";
	}*/

	public PersonalSearchService getPersonalSearchService() {
		return personalSearchService;
	}

	public void setPersonalSearchService(
			PersonalSearchService personalSearchService) {
		this.personalSearchService = personalSearchService;
	}

	public String getCreditName() {
		return creditName;
	}

	public List<Personalbasic> getPersonalList() {
		return personalList;
	}

	public void setPersonalList(List<Personalbasic> personalList) {
		this.personalList = personalList;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Integer getClientID() {
		return clientID;
	}

	public void setClientID(Integer clientID) {
		this.clientID = clientID;
	}

	public Personalbasic getPerson() {
		return person;
	}

	public void setPerson(Personalbasic person) {
		this.person = person;
	}

	public List<UsrUser> getUserList() {
		return userList;
	}

	public void setUserList(List<UsrUser> userList) {
		this.userList = userList;
	}

	public FindAllUserService getFindAllUserService() {
		return findAllUserService;
	}

	public void setFindAllUserService(FindAllUserService findAllUserService) {
		this.findAllUserService = findAllUserService;
	}

	public Customgrant getCustomgrant() {
		return customgrant;
	}

	public void setCustomgrant(Customgrant customgrant) {
		this.customgrant = customgrant;
	}

	public String getCertificatenumber() {
		return certificatenumber;
	}

	public void setCertificatenumber(String certificatenumber) {
		this.certificatenumber = certificatenumber;
	}

	public List<AppLoantype> getLoantypeList() {
		return loantypeList;
	}

	public void setLoantypeList(List<AppLoantype> loantypeList) {
		this.loantypeList = loantypeList;
	}

	public AppLoantypeService getAppLoantypeService() {
		return appLoantypeService;
	}

	public void setAppLoantypeService(AppLoantypeService appLoantypeService) {
		this.appLoantypeService = appLoantypeService;
	}

	public CreatKeyService getCreatKeyService() {
		return creatKeyService;
	}

	public void setCreatKeyService(CreatKeyService creatKeyService) {
		this.creatKeyService = creatKeyService;
	}

	public int getAutoApplyId() {
		return autoApplyId;
	}

	public void setAutoApplyId(int autoApplyId) {
		this.autoApplyId = autoApplyId;
	}

	public List<?> getDcommonList() {
		return dcommonList;
	}

	public void setDcommonList(List<?> dcommonList) {
		this.dcommonList = dcommonList;
	}

	public DropDownService getDropDownService() {
		return dropDownService;
	}

	public void setDropDownService(DropDownService dropDownService) {
		this.dropDownService = dropDownService;
	}

	public List<?> getCulturaList() {
		return culturaList;
	}

	public void setCulturaList(List<?> culturaList) {
		this.culturaList = culturaList;
	}

	public String getApplydate() {
		return applydate;
	}

	public void setApplydate(String applydate) {
		this.applydate = applydate;
	}

	public int getIsLook() {
		return isLook;
	}

	public void setIsLook(int isLook) {
		this.isLook = isLook;
	}

}
